#include "gameprocess.h"
#include <QRandomGenerator>

GameProcess::GameProcess() {
    // 初始化54张牌
    for(int i=2; i<=10; i++){ //2-10的四色牌
        for(int j=0; j<4; j++){
            allCards.append(Card(QString("%1").arg(i), cardColor[j]));
        }
    }
    QString otherCard[4] = {"J", "Q", "K", "A"};
    for(int i=0; i<4; i++){ //J-A的四色牌
        for(int j=0; j<4; j++){
            allCards.append(Card(otherCard[i], cardColor[j]));
        }
    }
    allCards.append(Card("JOKER-A", nullptr)); //大王
    allCards.append(Card("JOKER-B", nullptr)); //小王
}

Card GameProcess::getOneRandomCard()
{
    int randomInt = QRandomGenerator::global()->bounded(allCards.size()); // 生成一个0到卡牌剩余数量-1之间的随机数
    Card card = allCards[randomInt];
    allCards.removeAt(randomInt);
    return card;
}
